<template>
  <div class="app-container">
    <el-container>
      <el-header>{{dataList.taskPlan.ticketName}}</el-header>
      <el-tag size="small">未验收</el-tag>
      <el-descriptions>
        <el-descriptions-item label="验收工单编号">{{dataList.acceptInf.acceptNum}}</el-descriptions-item>
        <el-descriptions-item label="所属区队">{{dataList.taskPlan.parentDeptName}}</el-descriptions-item>
        <el-descriptions-item label="班组">{{dataList.taskPlan.deptName}}</el-descriptions-item>
        <el-descriptions-item label="班组长">{{dataList.taskPlan.morName}}</el-descriptions-item>
        <el-descriptions-item label="施工人">{{dataList.worker}}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions title="任务详情">
        <el-descriptions-item label="施工地点">{{dataList.taskPlan.borerLoc}}</el-descriptions-item>
        <el-descriptions-item label="钻机编号">{{dataList.borerInf.borerNum}}</el-descriptions-item>
        <el-descriptions-item label="钻机型号">{{dataList.borerInf.borerType}}</el-descriptions-item>
        <el-descriptions-item label="钻孔编号">{{dataList.drillInf.borerId}}</el-descriptions-item>
        <el-descriptions-item label="钻孔类型">{{dataList.drillInf.borerType}}</el-descriptions-item>
        <el-descriptions-item label="计划进尺">{{dataList.taskPlan.poreDepth}}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions title="人工填报内容">
        <el-descriptions-item label="施工地点">{{dataList.taskPlan.borerLoc}}</el-descriptions-item>
        <el-descriptions-item label="孔径">{{dataList.drillInf.poreSize}}</el-descriptions-item>
        <el-descriptions-item label="方位角">{{dataList.drillInf.mainAngle}}</el-descriptions-item>
        <el-descriptions-item label="人工计数">{{dataList.acceptInf.laborCount}}</el-descriptions-item>
        <el-descriptions-item label="钻孔类型">{{dataList.drillInf.borerType}}</el-descriptions-item>
        <el-descriptions-item label="倾角">{{dataList.drillInf.brakeTorque}}</el-descriptions-item>
        <el-descriptions-item label="开孔高度">{{dataList.drillInf.poreHigh}}</el-descriptions-item>
        <el-descriptions-item label="当班进尺">{{dataList.acceptInf.classFootage}}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions title="AI计数" v-if="inWay">
        <el-descriptions-item label="录制开始时间">{{dataList.aiInf.startTime}}</el-descriptions-item>
        <el-descriptions-item label="录制结束时间">{{dataList.aiInf.ddlTime}}</el-descriptions-item>
        <el-descriptions-item label="作业时长">{{dataList.aiInf.totalTime}}分钟</el-descriptions-item>
        <el-descriptions-item label="识别钻杆数">{{dataList.aiInf.countSum}}</el-descriptions-item>
        <el-descriptions-item label="完成率">{{wcl}}</el-descriptions-item>
      </el-descriptions>
      <el-tag size="small" v-else>视频正在分析中</el-tag>
      <el-container v-if="inWay">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-form-item label="验收计数" prop="acceptCount">
            <el-input v-model="form.acceptCount" placeholder="请输入验收计数" />
          </el-form-item>
          <el-form-item label="视频验收情况" prop="videoCondition">
            <el-select v-model="form.videoCondition" placeholder="请选择视频验收情况" clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in videopion" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="验收意见" prop="overallOpinion">
            <el-input v-model="form.overallOpinion" type="textarea" placeholder="请输入验收意见" />
          </el-form-item>
          <el-button type="primary" @click="submitForm">验 收</el-button>
        </el-form>
      </el-container>
    </el-container>
    </div>
</template>

<script>
import { getS, ysTask } from "@/api/system/uss";

export default {
  name: "Pore",
  dicts: ['sys_normal_disable'],
  data() {
    return {
      wcl:undefined,
      inWay:true,
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      dataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        borerId: undefined,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        acceptCount: [
          { required: true, message: "验收计数不能为空", trigger: "blur" }
        ],
        videoCondition: [
          { required: true, message: "视频验收情况不能为空", trigger: "blur" }
        ],
        overallOpinion: [
          { required: true, message: "验收意见不能为空", trigger: "blur" }
        ]
      },
      videopion:[{
          value: '视频完整，清晰',
          label: '视频完整，清晰'
        },{
        value: '视频完整，不清晰',
        label: '视频完整，不清晰'
      },{
        value: '视频不完整',
        label: '视频不完整'
      }]
    };
  },
  created() {
    this.first_one();
  },
  methods: {
    first_one(){
      getS(this.$route.query.id).then(response =>{
        this.dataList=response.data;
        if(this.dataList.aiInf!=null)
        {
          this.wcl = this.dataList.aiInf.countSum / this.dataList.taskPlan.poreDepth;
          this.wcl = Number(this.wcl * 100).toFixed(1) + '%';
        }
        else {
          this.inWay=false;
        }
      })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        borerId: undefined,
        drillExplain: undefined
      };
      this.resetForm("form");
    },
    /** 提交按钮 */
    submitForm: function() {
      const id=this.dataList.acceptInf.acceptId;
      this.$refs["form"].validate(valid => {
        if (valid) {
          ysTask(this.form,id).then(response => {
            this.$modal.msgSuccess("验收成功");
          });
        }
      });
    },
  }
};
</script>
